XfArtyShellTrail = {
	private ["_shpos", "_trails", "_ns", "_sh", "_trail"];
	_shpos = _this select 0;
	_trails = _this select 1;
	_ns = _this select 2;
	if (_trails != "") then {
		_sh = _ns createVehicleLocal [_shpos select 0, _shpos select 1, 150];
		_sh setPosASL _shpos;
		_sh setVelocity [0,0,-150];
		_trail = [_sh] call compile preprocessFile _trails;
		waitUntil {isNull _sh};
		sleep 1;
		deleteVehicle _trail;
	};
};

XGreyText = {"<t color='#f0bfbfbf'>" + _this + "</t>"};
XRedText = {"<t color='#f0ff0000'>" + _this + "</t>"};
XBlueText = {"<t color='#f07f7f00'>" + _this + "</t>"}; //olive
XPurpleText = {"<t color='#f05555ff'>" + _this + "</t>"}; //Blue purple
XGreenText = {"<t color='#f031723A'>" + _this + "</t>"}; //Forest Green
XLightGreenText = {"<t color='#f031E03A'>" + _this + "</t>"}; //Shiny Green

XfAlive = {
	private ["_alive"];
	_alive = false;
	if (alive player) then {
		if (isnil {player getVariable "NORRN_unconscious"}) then {
			_alive = alive player;
		} else {
			_alive = !(player getVariable "NORRN_unconscious");
		};
	};
	// diag_log format["XfAlive: %1",[_alive,alive player,(player getVariable "NORRN_unconscious")]];
	_alive;
};

// [Weapons, Magazines, Items, [Backpack,Weaps, Mags], PriWeapItems, SecWeapItems]
D_PLAYER_EQUIPMENT = [[],[],[],["",[],[]],[],[]];
XfSaveEquipment = {
	if (!local player || !alive player || isnull player) exitWith {diag_log format["XfSaveEquipment: %1",[!local player,!alive player,isnull player]];};
	private ["_weapons","_items","_magazines","_pweapitems","_sweapitems","_weap","_ubp","_ubackp","_oabackpackmags","_oabackpackweaps","_indexer","_counters","_item","_hgunitems","_accessories","_magazinesdetails"];
	_weapons = weapons player;
	_items = items player;
	_magazines = magazines player;
	_magazinesdetails = magazinesDetail player;
	_pweapitems = primaryWeaponItems player;
	_sweapitems = secondaryWeaponItems player;
	_hgunitems = handgunItems player;
	_oabackpackmags = [];
	_oabackpackweaps = [];
	
	_weap = primaryWeapon player;
	if (!isnil "_weap") then { if (_weap != "") then { if ((_weapons find _weap) < 0) then { _weapons set [count _weapons, _weap]; }; }; };
	_weap = secondaryWeapon player;
	if (!isnil "_weap") then { if (_weap != "") then { if ((_weapons find _weap) < 0) then { _weapons set [count _weapons, _weap]; }; }; };
	
	_accessories = [];
	{ _accessories = [_accessories,(player weaponAccessories _x)] call XfArrayPushStack;
	} foreach _weapons;
	// Items contain all magazines aswell.. so everything in magazines has to be removed from items
	_items = _items - _magazines;
	
	// the backpack magazines are already stored in the magazines
	_ubackp = "";

	_ubp = unitBackpack player;
	_ubackp = if (!isNull _ubp) then {typeOf _ubp} else {""};
	if (_ubackp != "") then {
		_oabackpackmags = getMagazineCargo _ubp;
		_oabackpackweaps = getWeaponCargo _ubp;
	};
	if (count _oabackpackmags > 0) then {
		_indexer = _oabackpackmags select 0;
		_counters = _oabackpackmags select 1;
		for [{_i = 0},{_i < count _indexer},{_i = _i + 1}] do {
			_item = _indexer select _i;
			if ((_magazines find _item) >= 0) then {
				_indexer set [_i, "XxDelxX"];
				_counters set [_i, "XxDelxX"];
			};
		};
		_indexer = _indexer - ["XxDelxX"];
		_counters = _counters - ["XxDelxX"];
		_oabackpackmags = [_indexer,_counters];
	};
	if (count _oabackpackweaps > 0) then {
		_indexer = _oabackpackweaps select 0;
		_counters = _oabackpackweaps select 1;
		for [{_i = 0},{_i < count _indexer},{_i = _i + 1}] do {
			_item = _indexer select _i;
			if ((_weapons find _item) >= 0) then {
				_indexer set [_i, "XxDelxX"];
				_counters set [_i, "XxDelxX"];
			};
		};
		_indexer = _indexer - ["XxDelxX"];
		_counters = _counters - ["XxDelxX"];
		_oabackpackweaps = [_indexer,_counters];
	};
	D_PLAYER_EQUIPMENT = [_weapons,_magazines,_items,[_ubackp,_oabackpackweaps,_oabackpackmags],_pweapitems,_sweapitems,_hgunitems,_accessories,_magazinesdetails];
	// diag_log format["XfSaveEquipment: %1",D_PLAYER_EQUIPMENT];
};